<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>页面滚动事件</title>
    <style>
        body {
            height: 3000px;
        }
    </style>
</head>
<body>
    <button>去底部</button>
    <script>
        window.addEventListener('scroll', function(){
            // html滚动的像素
            console.log(document.documentElement.scrollTop);
        })

        const btn = document.querySelector('button')
        btn.addEventListener('click', function(){
            document.documentElement.scrollTop = 3000
        })

        // 获取元素宽高，不包含边框长度
        console.log(btn.clientWidth)
        console.log(btn.clientHeight);

        // 视口宽度变化事件
        window.addEventListener('resize', function(){
            console.log('视口大小发送变化');
        })
    </script>
</body>
</html>